import request from '@/utils/request'

// 查询视频管理列表
export function listVideo(query) {
  return request({
    url: '/admin/video/list',
    method: 'get',
    params: query,
  })
}

// 删除视频管理
export function updateShowFlag(id) {
  return request({
    url: '/admin/video/updateShowFlag/' + id,
    method: 'put',
  })
}

// 删除视频管理
export function delVideo(id) {
  return request({
    url: '/admin/video/' + id,
    method: 'delete',
  })
}

//新增视频
export function saveVideo(data) {
  return request({
    url: '/admin/video/save',
    method: 'post',
    data: data,
  })
}

//获取视频签名
export function videoSignature() {
  return request({
    url: '/admin/video/getVideoSignature',
    method: 'get'
  })
}
//视频上传
export function uploads(params, file) {
  return request({
    url: '/admin/upload/uploadImg/3',
    method: 'post',
    data: params,
    onUploadProgress: progressEvent => {
      let percent = (progressEvent.loaded / progressEvent.total * 100) | 0
      //调用onProgress方法来显示进度条，需要传递个对象 percent为进度值
      file.onProgress({percent: percent})
    }
  })
}

//视频推荐
export function recommend(data) {
  return request({
    url: '/admin/video/recommend',
    method: 'put',
    data:data
  })
}

// 视频发布人列表
export function videolistUser(query) {
  return request({
    url: '/admin/video/listUserId',
    method: 'get',
    params: query
  })
}


export function auditVideo(data) {
  return request({
    url: '/admin/video/audit',
    method: 'put',
    data:data
  })
}

export function release(data) {
  return request({
    url: '/admin/video/release',
    method: 'put',
    data:data
  })
}

export function unRelease(videoId) {
  return request({
    url: '/admin/video/unRelease/' + videoId,
    method: 'put',
  })
}

